﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rbac.Project.Application.Roles;
using Rbac.Project.Application.Roles.Dto;
using Rbac.Project.WebApi.Filters;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Rbac.Project.WebApi.Controllers
{
    [Route("[controller]/[action]")]
    [ApiController]
    //[CustomerAuthorizationFilter]
    public class RoleController : ControllerBase
    {
        private readonly IRoleService service;

        public RoleController(IRoleService service)
        {
            this.service = service;
        }

        [HttpGet]
        public async Task<IActionResult> PageAsync(int PageIndex = 1, int PageSize = 10)
        {
            return Ok(await service.PageDataTupleAsync(PageIndex, PageSize));
        }

        [HttpPost]
        public async Task<IActionResult> AssignPermission(PermissionDto dto)
        {
            return Ok(await service.AssignPermissionAsync(dto));
        }

        [HttpPost]
        public IActionResult Test(int[] Arr)
        {
            return Ok();
        }

        [HttpGet]
        public async Task<IActionResult> InitPermission(int RoleId)
        {
            return Ok(await service.InitPermission(RoleId));
        }
    }
}
